<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /*call继承
        只能继承父类私有的属性或方法，无法继承原型上的
        父类私有变为子类私有的
        */
      function A(x) {
        this.x = x;
      }
      A.prototype.getX = function () {
        console.log(this.x);
      };
      function B(y) {
        A.call(this, 200);
        this.y = y;
      }

      B.prototype.getY = function () {
        console.log(this.y);
      };
      let b1 = new B(100);
      console.log(b1.y); //100
      console.log(b1.getY()); //会去执行getY

      console.log(b1.x); //100
      console.log(b1.getX()); //无法继承原型链上的属性或方法
    </script>
  </body>
</html>
